import { GET, POST } from "@/api";
import { config } from "@/config";
import { VagueOject } from "@/types/common";
import { ArticleType, ArticleInfoType } from "@/types/response/home";

export const app_articleList = async (data: VagueOject = {}, header: VagueOject = {}): Promise<ArticleType<string, string>[]> => {
    return await GET<ArticleType<string, string>[]>({ 
        baseUrl: app_articleList.prototype.base,
        url: app_articleList.prototype.url,
        data,
        header
    })
}

export const app_pushComment = async (data: VagueOject = {}, header: VagueOject = {}): Promise<null> => {
    return await POST<null>({ 
        baseUrl: app_pushComment.prototype.base,
        url: app_pushComment.prototype.url,
        data,
        header
    })
}



export const app_articleInfo = async (data: VagueOject = {}, header: VagueOject = {}): Promise<ArticleInfoType> => {
    let res =  await GET<ArticleInfoType>({ 
        baseUrl: app_articleInfo.prototype.base,
        url: app_articleInfo.prototype.url,
        data,
        header
    })

    res.loading = false
    res.page = 1
    res.total_page = 2

    res.article_comment.forEach((v: any) => {
        v.loading = false
        v.page = 1
        v.total_page = 3
    });
    return res
}




export const app_linkList = async (data: VagueOject = {}, header: VagueOject = {}): Promise<null> => {
    return await GET<null>({ 
        baseUrl: app_linkList.prototype.base,
        url: app_linkList.prototype.url,
        data,
        header
    })
}


